package fast.calc.monk;

import fast.calc.AttackType;
import fast.calc.Attacks;
import fast.calc.AttacksBlock;
import fast.calc.WeaponStats;
import fast.data.Stat;

public class AttacksMonk extends Attacks {
	
	double spellScaling90 = 1094.739746093750000;
	
	public AttacksMonk(FastMonk f){
		super(f);
		spellScaling = spellScaling90;
	}
	
	public AttacksBlock get_dmg_mh(){
		WeaponStats w = s.getMh();
		double damage = w.getSpeed() * ( w.getDps() + s.getBuffed(Stat.ap) / 14.);
		if(!w.getType().isTwoHander())
			damage *= 1.4;
		double crit_damage = damage * s.getCritMultiplier();
		return new AttacksBlock("mh",AttackType.physical, damage, crit_damage);
	}
	
	public AttacksBlock get_dmg_oh(){
		WeaponStats w = s.getOh();
		double damage = w.getSpeed() * ( w.getDps() + s.getBuffed(Stat.ap) / 14.);
		double mod = 0.5;
		damage *= mod;
		//if using dual wield one hander 40% extra dmg;
		damage *= 1.4;
		double crit_damage = damage * s.getCritMultiplier();
		return new AttacksBlock("oh",AttackType.physical, damage, crit_damage);
	}
	
	public double get_crit_mh(){
		double crit_chance = s.getCritPercent();
		return crit_chance;
	}
	
	public double get_crit_oh(){
		return get_crit_mh();
	}
	
	public AttacksBlock get_dmg_tiger_strike_mh(){
		WeaponStats w = s.getMh();
		double damage = w.getSpeed() * ( w.getDps() + s.getBuffed(Stat.ap) / 14.);
		double crit_damage = damage * s.getCritMultiplier();
		return new AttacksBlock("tiger_strike_mh",AttackType.physical, damage, crit_damage);
	}
	
	public AttacksBlock get_dmg_tiger_strike_oh(){
		WeaponStats w = s.getOh();
		double damage = w.getSpeed() * ( w.getDps() + s.getBuffed(Stat.ap) / 14.);
		double mod = 0.5;
		damage *= mod;
		double crit_damage = damage * s.getCritMultiplier();
		return new AttacksBlock("tiger_strike_oh",AttackType.physical, damage, crit_damage);
	}
	
	public double get_crit_tiger_strike_mh(){
		return get_crit_mh();
	}
	
	public double get_crit_tiger_strike_oh(){
		return get_crit_oh();
	}
	
	public AttacksBlock get_dmg_jab(){
		WeaponStats w = s.getMh();
		WeaponStats oh = s.getOh();
		double damage = w.getDps();
		double damage_oh = oh.getDps();
		if(w.getType().isTwoHander())
			damage_oh = 0.0;
		double extra_damage = s.getBuffed(Stat.ap) / 14.;
		double mod = 1.5;
		damage = (((damage + 0.5 * damage_oh) * getWeaponTypeMod()) + extra_damage) * mod;
		
		double crit_damage = damage * s.getCritMultiplier();
		
		return new AttacksBlock("jab",AttackType.physical, damage, crit_damage);
	}
	
	public double get_crit_jab(){
		return get_crit_mh();
	}
	
	public AttacksBlock get_dmg_tiger_palm(){
		WeaponStats w = s.getMh();
		WeaponStats oh = s.getOh();
		double damage = w.getDps();
		double damage_oh = oh.getDps();
		if(w.getType().isTwoHander())
			damage_oh = 0.0;
		double extra_damage = s.getBuffed(Stat.ap) / 14.;
		double mod = 3;
		damage = (((damage + 0.5 * damage_oh) * getWeaponTypeMod()) + extra_damage) * mod;
		
		double crit_damage = damage * s.getCritMultiplier();
		
		return new AttacksBlock("tiger_palm",AttackType.physical, damage, crit_damage);
	}
	
	public double get_crit_tiger_palm(){
		return get_crit_mh();
	}
	
	public AttacksBlock get_dmg_blackout_kick(){
		WeaponStats w = s.getMh();
		WeaponStats oh = s.getOh();
		double damage = w.getDps();
		double damage_oh = oh.getDps();
		if(w.getType().isTwoHander())
			damage_oh = 0.0;
		double extra_damage = s.getBuffed(Stat.ap) / 14.;
		double mod = 8;
		damage = (((damage + 0.5 * damage_oh) * getWeaponTypeMod()) + extra_damage) * mod;
		
		double crit_damage = damage * s.getCritMultiplier();
		
		return new AttacksBlock("blackout_kick",AttackType.physical, damage, crit_damage);
	}
	
	public double get_crit_blackout_kick(){
		return get_crit_mh();
	}
	
	public AttacksBlock get_dmg_blackout_kick_dot(){
		AttacksBlock bk = get_dmg_blackout_kick();
		double crit_chance = get_crit_blackout_kick();
		
		double damage = bk.getHitDamage() * (1-crit_chance) + bk.getCritDamage() * crit_chance;
		double mod = 0.2;
		damage *= mod;
		
		double crit_damage = damage * s.getCritMultiplier();
		
		return new AttacksBlock("blackout_kick_dot",AttackType.bleed, damage, crit_damage);
	}
	
	public double get_crit_blackout_kick_dot(){
		return 0.0; // can not crit
	}
	
	public AttacksBlock get_dmg_rising_sun_kick(){
		WeaponStats w = s.getMh();
		WeaponStats oh = s.getOh();
		double damage = w.getDps();
		double damage_oh = oh.getDps();
		if(w.getType().isTwoHander())
			damage_oh = 0.0;
		double extra_damage = s.getBuffed(Stat.ap) / 14.;
		double mod = 14.4;
		damage = (((damage + 0.5 * damage_oh) * getWeaponTypeMod()) + extra_damage) * mod;
		
		double crit_damage = damage * s.getCritMultiplier();
		
		return new AttacksBlock("rising_sun_kick",AttackType.physical, damage, crit_damage);
	}
	
	public double get_crit_rising_sun_kick(){
		return get_crit_mh();
	}
	
	public AttacksBlock get_dmg_fists_of_fury(){
		WeaponStats w = s.getMh();
		WeaponStats oh = s.getOh();
		double damage = w.getDps();
		double damage_oh = oh.getDps();
		if(w.getType().isTwoHander())
			damage_oh = 0.0;
		double extra_damage = s.getBuffed(Stat.ap) / 14.;
		double mod = 7.5;
		damage = (((damage + 0.5 * damage_oh) * getWeaponTypeMod()) + extra_damage) * mod;
		
		double crit_damage = damage * s.getCritMultiplier();
		
		return new AttacksBlock("fists_of_fury",AttackType.physical, damage, crit_damage);
	}
	
	public double get_crit_fists_of_fury(){
		return get_crit_mh();
	}
	
	public AttacksBlock get_dmg_xuen_dot(){
		double base_damage = 0.2930000126 * spellScaling;
									// divide by 5 because of 5 ticks
		double damage = base_damage + 0.505 / 5 * s.getBuffed(Stat.ap);
		double crit_damage = damage * s.getCritMultiplier();
		
		return new AttacksBlock("xuen_dot",AttackType.magical,damage, crit_damage);
	}
	
	public double get_crit_xuen_dot(){
		return get_crit_mh();
	}
	
	public AttacksBlock get_dmg_xuen_melee(){
		WeaponStats w = s.getMh();
		double damage = w.getDps() * w.getSpeed();
		double crit_damage = damage * s.getCritMultiplier();
		return new AttacksBlock("xuen_melee",AttackType.physical,damage, crit_damage);
	}
	
	public double get_crit_xuen_melee(){
		return get_crit_mh();
	}
	
	private double getWeaponTypeMod(){
		if(!s.getMh().getType().isTwoHander())
			return 0.8988882;
		return 1.0;
	}

}
